package com.ybkj.daijia.server.mapper;

import com.ybkj.daijia.server.model.DriverPaymentsRecord;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;

public interface DriverPaymentsRecordMapper {

    /**
     * 保存司机充值记录
     *
     * @param record
     * @return
     */
    long insertRecord(DriverPaymentsRecord record);

    /**
     * 根据主键查询司机充值记录
     *
     * @param id
     * @return
     */
    DriverPaymentsRecord selectByPrimaryKey(Long id);


    /**
     * 根据主键删除司机充值记录
     *
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Long id);

    /**
     * 根据司机id删除司机充值记录
     *
     * @return
     */
    int deleteByDriverId(Long driverId);

    /**
     * 根据主键修改司机充值记录
     *
     * @param record
     * @return
     */
    int updateByPrimaryKey(DriverPaymentsRecord record);

    List<DriverPaymentsRecord> listIndexPayments(@Param("driverId") Long driverId,
        @Param("start") Date start, @Param("end") Date end);

    BigDecimal sumInComeByEmployWithDate(@Param("driverId") Long driverId,
        @Param("start") Date start, @Param("end") Date end);

    BigDecimal sumRebateByEmployWithDate(@Param("driverId") Long driverId,
        @Param("start") Date start, @Param("end") Date end);

    List<DriverPaymentsRecord> selectByEmploy(@Param("driverId") Long driverId,
        @Param("recordType") String recordType, @Param("rcType") Integer rcType,
        @Param("start") Date start, @Param("end") Date end, @Param("offset") Integer offset,
        @Param("size") Integer size);

    List<Map<String, Object>> selectByEmploy2(@Param("driverId") Long driverId,
        @Param("recordType") String recordType, @Param("rcType") Integer rcType,
        @Param("start") Date start, @Param("end") Date end, @Param("offset") Integer offset,
        @Param("size") Integer size);

    List<DriverPaymentsRecord> select(@Param("driverId") Long driverId,
        @Param("recordType") String recordType, @Param("rcType") Integer rcType,
        @Param("start") Date start, @Param("end") Date end, @Param("offset") Integer offset,
        @Param("size") Integer size);

    long countByEmploy(@Param("driverId") Long driverId, @Param("recordType") String recordType,
        @Param("rcType") Integer rcType, @Param("start") Date start, @Param("end") Date end);

    List<DriverPaymentsRecord> selectByRecordTypeAndOrder(@Param("recordType") String recordType,
        @Param("orderId") Long orderId, @Param("orderType") Integer orderType);

    List<DriverPaymentsRecord> selectByRecordTypeAndDriver(@Param("recordType") String recordType,
        @Param("driverId") Long driverId, @Param("orderType") Integer orderType,
        @Param("start") Date start, @Param("end") Date end);

    BigDecimal sumPositiveMoneyByDriver(@Param("driverId") Long driverId,
        @Param("start") Date start, @Param("end") Date end);

    BigDecimal sumPositiveMoneyByCompany(@Param("companyId") Long companyId,
        @Param("name") String name, @Param("start") Date start, @Param("end") Date end);

    BigDecimal sumMoneyByCompany(@Param("companyId") Long companyId, @Param("start") Date start,
        @Param("end") Date end);

    List<DriverPaymentsRecord> selectRecharge(Map<String, Object> params);

    long countRecharge(Map<String, Object> params);

    BigDecimal sumRecharge(@Param("companyId") Long companyId,
        @Param("recordType") String recordType, @Param("name") String name,
        @Param("start") Date start, @Param("end") Date end);

    List<DriverPaymentsRecord> findOrderRecharge(@Param("driverId") Long driverId,
        @Param("orderId") Long orderId, @Param("orderType") Integer orderType);

    List<DriverPaymentsRecord> findDriverRebateRewardByPhoneAndDriverUserName(
        @Param("phone") String phone, @Param("userName") String userName);

    DriverPaymentsRecord findHasDriverGetRebate(@Param("phone") String phone);

    Long countByEmployAndRecordTypeCollections(@Param("driverId") Long driverId,
        @Param("rcType") Integer rcType, @Param("start") Date start, @Param("end") Date end,
        @Param("recordTypes") String... recordTypes);

    List<DriverPaymentsRecord> selectByEmployAndRecordTypeCollections(
        @Param("driverId") Long driverId, @Param("rcType") Integer rcType,
        @Param("start") Date start, @Param("end") Date end, @Param("offset") Integer offset,
        @Param("size") Integer size, @Param("recordTypes") String... recordType);
}
